package com.kelly.xml;

import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.w3c.dom.NodeList;

public class Main {

	private final static String xmlString =  "<bizi name=\"bizi\" type=\"biziType\"><bizi1 name=\"bizi1\" valueType=\"bizi2Type\">bizi1</bizi1><bizi1 name=\"module\"><bizi1 name=\"bizi12\" valueType=\"url\">bizi1URL</bizi1><bizi21 name=\"bizi211\">bizi211Value</bizi21><bizi21 name=\"bizi212\" value=\"bizi212Value\" /></bizi1></bizi>";
	private final static String xPathExpression = "/bizi/bizi1[@name='module']/*[@valueType='url']";
	public static void main(String[] args) {
		// 测试Node
		NodeList nodeList = SearchXml.searchNodeListByXpath(xmlString, xPathExpression);
		if (nodeList!=null) {
			System.out.println(nodeList.item(0).getTextContent());
		}
		
		//测试NodeValue
		List<String> result = SearchXml.getValueByXPath(xmlString, xPathExpression);
		if(!CollectionUtils.isEmpty(result)){
			for(String string : result){
				System.out.print(string+"\t");
			}
			System.out.println();
		}
	}
}
